<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (!function_exists('get_uid')){
	/**
	 * 获取登录用户id
	 * @return number
	 */
	function get_uid(){
		$ci = &get_instance();
		$ci->load->library('session');
		return (int) $ci->session->userdata('uid');
	}
}

if (!function_exists('get_avatar')) {
	/**
	 * 获取用户头像
	 * @param integer $uid
	 * @param integer $size
	 */
	function get_avatar($uid=0,$size=100){
		if (!$uid){
			$uid = get_uid();
		}
		$ci = &get_instance();
		
		$avatar = $ci->config->item('avatar_path').$uid.'_'.$size.'.jpg';
		
		if (!is_file($avatar)){
			$avatar = $ci->config->item('theme_path').'img/avatar/'.$size.'.png';
		}
		$avatar = str_replace('./', '/', $avatar);
		return $avatar;
	}
}

if (!function_exists('get_video_code')){
	function get_video_code($url){
		$uinfo = parse_url($url);
		$domain = $uinfo['host'];
		switch ($domain){
			case 'v.youku.com':
				
		}
	}
}